import MSData
import WorkerPCNFirebird
import WorkerMSAPI
import WorkerCesar
import MSLogger
import MSConfig

import time
import sys

MSLogger.logInit('/root/magicsys/ms.log', 5, True)
reader      = WorkerMSAPI.Worker()
#reader.connect()

writerPCN   = WorkerPCNFirebird.Worker('firebird-1.spb.csat:/var/lib/firebird2/data/pcn6.fdb', 'SYSDBA', 'masterkey')
writerPCN.connect()

writerCesar = WorkerCesar.Worker('empo-fet.msk.csat.ru', '25544')
writerCesar.connect()

objects = MSConfig.readObjectsConfig('objects.cfg')


while True:
    reader.readEventsPGSM(objects)
    reader.readEventsContactId(objects)
    #writerPCN.writeEventsStatic(objects)
    writerCesar.writeEventsStatic(objects)
    for o in objects:
        o.eventsContactId = []
        o.eventsPGSM = []
    time.sleep(5)

